package com.runnor.common.websys.system.security;

import cn.hutool.core.util.StrUtil;
import lombok.NoArgsConstructor;
import org.springframework.security.authentication.BadCredentialsException;
import org.springframework.security.crypto.bcrypt.BCrypt;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Component;

/**
 * @author runnor-yh
 * @date 2023年08月15日 14:51
 */
@NoArgsConstructor
public class PasswordEncoder extends BCryptPasswordEncoder {
//    @Override
//    public boolean matches(CharSequence rawPassword, String encodedPassword) {
//        String pwd = rawPassword.toString();
//        // 进行rsa解密
//        try {
////            pwd = RsaUtils.decryptByPrivateKey(RsaProperties.privateKey, pwd);
//        } catch (Exception e) {
//            throw new BadCredentialsException(e.getMessage());
//        }
//        if (StrUtil.isNotBlank(encodedPassword)) {
//            return BCrypt.checkpw(pwd, encodedPassword);
//        } else {
//            return false;
//        }
//    }
}
